package com.example.plus5;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

import android.location.Location;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.text.format.DateFormat;
import android.text.format.Time;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class AddAppointment extends Activity {

	private EditText appointmentDestinationET;
	private EditText appointmentDayET;
	private EditText appointmentTimeET;
	private EditText appointmentNameET;

	private String appointmentDestinationSt;
	private Location appointmentDestination;
	private String appointmentName;
	private String appointmentDay;
	private String appointmentTimeSt;
	private Date appointmentTime;	
	private appointment appointmentRet;
	public final static String EXTRA_MESSAGE = "com.example.plus5.MESSAGE";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_appointment);
		appointmentDestinationET = (EditText) findViewById(R.id.appointmentDestinationET);
		appointmentDayET = (EditText) findViewById(R.id.appointmentDayET);
		appointmentTimeET = (EditText) findViewById(R.id.appointmentTimeET);
		appointmentNameET = (EditText) findViewById(R.id.appointmentNameET);
		
		appointmentDestinationET.setText(null);
		appointmentDayET.setText(null);
		appointmentTimeET.setText(null);
		appointmentNameET.setText(null);


	}

	public void setDestinationAndAlarm(View v){

		String appointmentDay = appointmentDayET.getText().toString();
		String appointmentName = appointmentNameET.getText().toString();
		String appointmentDestinationSt = appointmentDestinationET.getText().toString();
		String appointmentTimeSt = appointmentTimeET.getText().toString();

		


		/*SimpleDateFormat formatter = new SimpleDateFormat("hh:mm a");
		try{
			appointmentTime =(Date) formatter.parse(appointmentTimeSt);
		}catch (Exception e){	
		}*/

		//appointmentDestination = appointmentDestinationSt;
		appointmentRet = new appointment(appointmentName, appointmentDestinationSt,
										 appointmentDay, appointmentTimeSt);

		/*if(appointmentDestinationET == null && appointmentDayET == null && appointmentTimeET== null && appointmentNameET == null){
			Intent set = new Intent(AddAppointment.this, Appointments.class);*/

		//	set.putExtra("appointment", appointment);
		Intent intent = new Intent (this, Appointments.class);
		intent.putExtra("New_Appointment", appointmentRet);


		startActivity(intent);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.add_appointment, menu);
		return true;
	}

}



